package com.legolas.provider.api.testapi;


import com.alibaba.dubbo.config.annotation.Service;
import com.legolas.api.service.TestService;

@Service(version = "1.0.0", interfaceClass = com.legolas.api.service.TestService.class, group = "group2")
public class TestService2API implements TestService {

    /*
    @HystrixCommand(
            threadPoolKey = "service1ThreadPool",
            threadPoolProperties = {
                    @HystrixProperty(name = "coreSize", value = "2"),
                    @HystrixProperty(name = "maxQueueSize", value = "20")
            }
            commandProperties = {
                    @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "2"),//最小请求数2
                    @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "3000"),//时间窗3s
                    @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "50"),//失败百分比
                    @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "3000")//活动窗口3s
            }
    )*/
    @Override
    public String test(String msg) {
        if (Math.random() < 0.5) {
            /*try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }*/
            throw new RuntimeException("自定义测试异常：testgroup2");
        }
        return "provider——group2提供的服务" + msg;
    }

    @Override
    public void queueProducer(String msg) {

    }
}
